package com.itjin.mapper;

import com.itjin.model.domain.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

/**
 * @author 胡
 * @description 针对表【user】的数据库操作Mapper
 * @createDate 2025-01-19 14:08:44
 * @Entity generator.domain.User
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

  /**
   * 统计指定时间段内的活跃用户数
   * 
   * @param startTime 开始时间
   * @param endTime   结束时间
   * @return 活跃用户数
   */
  @Select("SELECT COUNT(*) FROM user WHERE lastLoginTime >= #{startTime} AND lastLoginTime <= #{endTime}")
  Integer countActiveUsersByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

}
